import { defineStore } from 'pinia'
import { gettableListApi, getclassifyListApi, getdishesListApi, postOrderSaveApi, postTableApi } from '@/api/SimulatedOrderPlacing'

export const useSimulatedOrderPlacing = defineStore('SimulatedOrderPlacing', {
    state: () => {
        return {
            tableList: [],
            classifyList: [],
            dishesList: [],
            dishesListQuery1: ''
        }
    },
    getters: {

    },
    actions: {
        async getList() {
            const tableData = await gettableListApi({ query2: '0', query3: true })
            const classifyData = await getclassifyListApi({})
            const dishesData = await getdishesListApi({
                query1: this.dishesListQuery1
            })
            this.tableList = tableData.data
            this.classifyList = classifyData.data
            this.dishesList = dishesData.data
        },
        async postOrderSave(formValue: object) {
            await postOrderSaveApi(formValue)
        },
        modifyTableState({ _id, cut, number, position, status }) {
            postTableApi({ _id, state: '1', cut, number, position, status })
        }
    }
})